﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MethodWorx.CMS.TemplateLanguage.Design;
using MethodWorx.CMS.TemplateLanguage.Properties;

namespace MethodWorx.CMS.TemplateLanguage.Parsers.Html
{
    public class Layout : IParser, IDesignable
    {
        [Property]
        public bool North { get; set; }
        [Property]
        public bool South { get; set; }
        [Property]
        public bool East { get; set; }
        [Property]
        public bool West { get; set; }
        [Property]
        public string Tag { get; set; }

        public Layout()
        {
            this.Tag = "div";
        }

        #region IParser Members

        public object Parse(Web.CmsRequestContext context, IEnumerable<object> stack, Dictionary<string, object> parameters)
        {
            return "";
        }

        public string Name
        {
            get { return "Layout"; }
        }

        public string Namespace
        {
            get { return "Html"; }
        }

        #endregion

        #region IDesigner Members

        public void Design(IDesigner designer)
        {
            //
            //  ok, lets sort out the designer
            var c = designer.AddControl("Html:Layout");
                        //.SetTag(this.Tag);

            c.AddContentAfterChildren("content");
            if (this.North)
                c.AddChildControl("north");
            if (this.South)
                c.AddChildControl("south");
            if (this.East)
                c.AddChildControl("east");
            if (this.West)
                c.AddChildControl("west");
        }

        #endregion
    }
}
